package cn.edu.cdu.argorithm.impl;

import cn.edu.cdu.argorithm.IContainerWithMostWater;

public class ContainerWithMostWater implements IContainerWithMostWater {
    @Override
    public int maxArea(int[] height) {
        int ans = 0, left = 0, right = height.length - 1;
        while(left < right) {
            ans = Math.max(Math.min(height[left], height[right]) * (right - left), ans);
            if(height[left] > height[right]) {
                right--;
            } else {
                left++;
            }
        }
        return ans;
    }
}
